package com.example.llademo.manager;

import com.example.llademo.entity.ADSPosition;
import com.example.llademo.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zhangqi
 * @date 2024/4/2
 * @time 17:01
 * @description
 */
@Component
@Slf4j
public class AdsManager {


    /**
     * 根据lla卫星时间获取临近时间的飞行器（飞机）数据列表
     *
     * @param llaDate
     * @param adsPositionList
     * @return
     */
    public List<ADSPosition> getNearRangeListByDate(Date llaDate, List<ADSPosition> adsPositionList) {
        return adsPositionList.stream()
                //过去时间相同以及同分钟的数据
                .filter(ads ->{
                    log.info("ads time:{} lla time:{}",ads.getCaptureTime(),llaDate);
                    return ads.getCaptureTime().compareTo(llaDate) == 0
                            ||
                            DateUtil.timeFormatterUntilMinute(ads.getCaptureTime())
                                    .compareTo(DateUtil.timeFormatterUntilMinute(llaDate))
                                    == 0;
                }).collect(Collectors.toList());
    }
}
